/*数据操作类
Created on 2020年05月10日
@author: zxyong 13738196011
 */

package com.zxy.business;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;

import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;
import com.zxy.db4.Db_Common4;
import com.zxy.db_Self.*;
import com.zxy.model.*;

public class Ope_DB_Cent
{
	public int	iCount	= 0;

	public void Init_Load()
	{
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_param_value");
		Db_Common_Self db_self = new Db_Common_Self();
		ResultSet rs = db_self.Common_Sql(strSql);
		try
		{
			while(rs.next())
			{
				if(rs.getString("PARAM_KEY").equals("AccSocketPort"))
				{
					Com_Para.AccSocketPOrt = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("Inf_Name"))
				{
					Com_Para.Inf_Name = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("Child_Code"))
				{
					Com_Para.Child_Code = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
					Com_Para.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				}
				else if(rs.getString("PARAM_KEY").equals("ServerIP"))
				{
					Com_Para.ServerIP = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("ServerPort"))
				{
					Com_Para.ServerPort = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("TimeCount"))
				{
					Com_Para.TimeCount = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("If_Child_Device"))
				{
					Com_Para.If_Child_Device = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("If_Parent_Device"))
				{
					Com_Para.If_Parent_Device = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("TimeCount"))
				{
					Com_Para.TimeCount = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("HTTP_Path"))
				{
					Com_Para.HTTP_Path = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("Login_Session"))
				{
					Com_Para.Login_Session = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("Is_UserLogin"))
				{
					Com_Para.Is_UserLogin = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("InterSession"))
				{
					Com_Para.InterSession = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("APP_ID"))
				{
					Com_Para.APP_ID = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("APP_PRIVATE_KEY"))
				{
					Com_Para.APP_PRIVATE_KEY = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("U_CODE"))
				{
					Com_Para.U_CODE = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("AliPay_Check"))
				{
					Com_Para.AliPay_Check = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("AliPay_Check2"))
				{
					Com_Para.AliPay_Check2 = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("WxPay_Check"))
				{
					Com_Para.WxPay_Check = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("Ali_Login"))
				{
					Com_Para.Ali_Login = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("SessionTimeOut"))
				{
					Com_Para.SessionTimeOut = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("ShowSqlError"))
				{
					Com_Para.ShowSqlError = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("strSessionAva"))
				{
					Com_Para.strSessionAva = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("EncryptUtilType"))
				{
					Com_Para.EncryptUtilType = rs.getInt("PARAM_VALUE");
				}
				else if(rs.getString("PARAM_KEY").equals("CustTimeTaskNum"))
				{
					Com_Para.CustTimeTaskNum = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("CustTimeREFLECT_IN_CLASS"))
				{
					Com_Para.CustTimeREFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("ServerREFLECT_IN_CLASS"))
				{
					Com_Para.ServerREFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("ClientREFLECT_IN_CLASS"))
				{
					Com_Para.ClientREFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				}
				else if(rs.getString("PARAM_KEY").equals("ServerWebPort"))
				{
					Com_Para.ServerWebPort = rs.getInt("PARAM_VALUE");
				}
			}
			if(Com_Para.Child_Code.equals(""))
			{
				Com_Para.Child_Code = Com_Fun.Get_New_GUID().replaceAll("-","");
				strSql.delete(0,strSql.length());
				strSql.append("update t_param_value set PARAM_VALUE = '" + Com_Para.Child_Code + "' where PARAM_KEY = 'Child_Code'");
				db_self.CommonExec_Sql(strSql);
			}
			if(Com_Para.strSessionAva.equals(""))
			{
				Com_Para.strSessionAva = Com_Fun.setSconnections();
				strSql.delete(0,strSql.length());
				strSql.append("update t_param_value set PARAM_VALUE = '" + Com_Para.strSessionAva + "' where PARAM_KEY = 'strSessionAva'");
				db_self.CommonExec_Sql(strSql);
			}

			if(Com_Para.Child_Code.equals("2E71E37154914FA8A60A8BD72577F9F7") || Com_Para.Child_Code.equals(""))
			{
				Com_Para.Child_Code = Com_Fun.Get_New_GUID().replaceAll("-","");
				Change_Child_Code(Com_Para.Child_Code);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("初始化数据出错[Init_Load]\r\n" + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			if(rs != null)
			{
				try
				{
					rs.getStatement().close();
					rs.close();
				}
				catch(SQLException e)
				{
				}
			}
		}
	}

	public String Get_Child_Node(String param_name)
	{
		String strResult = "-1";
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		StringBuilder strSql = new StringBuilder();
		strSql.append("select b.CHILD_NODE from t_child_proc a left join t_child_node b " + " on a.CHILD_ID = b.MAIN_ID where INF_EN_NAME = '" + param_name + "'");
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				strResult = rs.getString("CHILD_NODE");
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_Child_Node]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_Child_Node]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return strResult;
	}

	public List<T_DB_CONFIG> Get_T_DB_CONFIG(int i)
	{
		List<T_DB_CONFIG> td = new ArrayList<T_DB_CONFIG>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_db_config where MAIN_ID = '" + i + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_DB_CONFIG tdc = new T_DB_CONFIG();
				tdc.setMAIN_ID(rs.getInt("MAIN_ID"));
				tdc.setDB_CN_NAME(Com_Fun.NoNull(rs.getString("db_cn_name")));
				tdc.setDB_DriverClassName(Com_Fun.NoNull(rs.getString("DB_driverClassName")));
				tdc.setDB_password(Com_Fun.NoNull(rs.getString("db_password")));
				tdc.setDB_url(Com_Fun.NoNull(rs.getString("db_url")));
				tdc.setDB_username(Com_Fun.NoNull(rs.getString("db_username")));
				tdc.setDB_version(Com_Fun.NoNull(rs.getString("db_version")));
				tdc.setDB_Code(Com_Fun.NoNull(rs.getString("db_code")));
				td.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_DB_CONFIG]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_DB_CONFIG]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public List<T_DB_CONFIG> Get_T_DB_CONFIG()
	{
		List<T_DB_CONFIG> td = new ArrayList<T_DB_CONFIG>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_db_config");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_DB_CONFIG tdc = new T_DB_CONFIG();
				tdc.setMAIN_ID(rs.getInt("MAIN_ID"));
				tdc.setDB_CN_NAME(Com_Fun.NoNull(rs.getString("db_cn_name")));
				tdc.setDB_DriverClassName(Com_Fun.NoNull(rs.getString("DB_driverClassName")));
				tdc.setDB_password(Com_Fun.NoNull(rs.getString("db_password")));
				tdc.setDB_url(Com_Fun.NoNull(rs.getString("db_url")));
				tdc.setDB_username(Com_Fun.NoNull(rs.getString("db_username")));
				tdc.setDB_version(Com_Fun.NoNull(rs.getString("db_version")));
				tdc.setDB_Code(Com_Fun.NoNull(rs.getString("db_code")));
				td.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_DB_CONFIG]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_DB_CONFIG]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public String Get_RptSave_Path()
	{
		String strResult = "";
		StringBuilder strSql = new StringBuilder("select * from t_param_value where PARAM_KEY='RptSave'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				strResult = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_RptTemp]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_RptTemp]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return strResult;
	}

	public String Get_RptTemp_Path()
	{
		String strResult = "";
		StringBuilder strSql = new StringBuilder("select * from t_param_value where PARAM_KEY='RptTemp'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				strResult = Com_Fun.NoNull(rs.getString("PARAM_VALUE"));
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_RptTemp]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_RptTemp]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return strResult;
	}

	public T_PROC_NAME Get_T_PROC_NAME(String INF_EN_NAME)
	{
		T_PROC_NAME td = new T_PROC_NAME();
		StringBuilder strSql = new StringBuilder();
		if(INF_EN_NAME != "")
		{
			strSql.append("select * from T_PROC_NAME where INF_EN_NAME = '" + INF_EN_NAME + "'");
		}
		else strSql.append("select * from t_proc_name");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.DB_ID = rs.getInt("DB_ID");
				td.INF_CN_NAME = Com_Fun.NoNull(rs.getString("INF_CN_NAME"));
				td.INF_EN_NAME = Com_Fun.NoNull(rs.getString("INF_EN_NAME"));
				td.INF_EN_SQL = Com_Fun.NoNull(rs.getString("INF_EN_SQL"));
				td.INF_TYPE = Com_Fun.NoNull(rs.getString("INF_TYPE"));
				td.REFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_IN_CLASS"));
				td.REFLECT_OUT_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_OUT_CLASS"));
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public Hashtable<Integer,cal_variables> Get_cal_variables()
	{
		Hashtable<Integer,cal_variables> tds = new Hashtable<Integer,cal_variables>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from cal_variables");
		Db_Common4 dbc4 = new Db_Common4();
		ResultSet rs = null;
		try
		{
			rs = dbc4.Common_Sql(strSql);
			while(rs.next())
			{
				cal_variables td = new cal_variables();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.VAR_NAME = Com_Fun.NoNull(rs.getString("VAR_NAME"));
				td.VAR_KEY = Com_Fun.NoNull(rs.getString("VAR_KEY"));
				td.VAR_TYPE = Com_Fun.NoNull(rs.getString("VAR_TYPE"));
				td.VAR_DESC = Com_Fun.NoNull(rs.getString("VAR_DESC"));
				td.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tds.put(td.MAIN_ID,td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_cal_variables]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_cal_variables]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tds;
	}

	public Hashtable<Integer,cal_fun> Get_cal_fun()
	{
		Hashtable<Integer,cal_fun> tds = new Hashtable<Integer,cal_fun>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from cal_fun");
		Db_Common4 dbc4 = new Db_Common4();
		ResultSet rs = null;
		try
		{
			rs = dbc4.Common_Sql(strSql);
			while(rs.next())
			{
				cal_fun td = new cal_fun();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.FUN_NAME = Com_Fun.NoNull(rs.getString("FUN_NAME"));
				td.FUN_DESC = Com_Fun.NoNull(rs.getString("FUN_DESC"));
				td.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tds.put(td.MAIN_ID,td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_fun]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_fun]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tds;
	}

	public Hashtable<String,cal_run> Get_cal_run()
	{
		Hashtable<String,cal_run> tds = new Hashtable<String,cal_run>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from cal_run");
		Db_Common4 dbc4 = new Db_Common4();
		ResultSet rs = null;
		try
		{
			rs = dbc4.Common_Sql(strSql);
			while(rs.next())
			{
				cal_run td = new cal_run();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.FUN_ID = rs.getInt("FUN_ID");
				td.RUN_CODE = Com_Fun.NoNull(rs.getString("RUN_CODE"));
				td.RUN_DESC = Com_Fun.NoNull(rs.getString("RUN_DESC"));
				td.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tds.put(td.RUN_CODE,td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tds;
	}

	public List<cal_run_param> Get_cal_run_param()
	{
		List<cal_run_param> tds = new ArrayList<cal_run_param>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from cal_run_param");
		Db_Common4 dbc4 = new Db_Common4();
		ResultSet rs = null;
		try
		{
			rs = dbc4.Common_Sql(strSql);
			while(rs.next())
			{
				cal_run_param td = new cal_run_param();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.RUN_ID = rs.getInt("RUN_ID");
				td.VARI_ID = rs.getInt("VARI_ID");
				td.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tds.add(td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run_param]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run_param]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tds;
	}

	public List<cal_run_step> Get_cal_run_step()
	{
		List<cal_run_step> tds = new ArrayList<cal_run_step>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from cal_run_step");
		Db_Common4 dbc4 = new Db_Common4();
		ResultSet rs = null;
		try
		{
			rs = dbc4.Common_Sql(strSql);
			while(rs.next())
			{
				cal_run_step td = new cal_run_step();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.CAL_STEP = Com_Fun.NoNull(rs.getString("CAL_STEP"));
				td.SETP_DESC = Com_Fun.NoNull(rs.getString("SETP_DESC"));
				td.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tds.add(td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run_param]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[cal_run_param]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tds;
	}

	public T_PROC_NAME Get_T_PROC_NAME(String INF_EN_NAME,int SUB_ID)
	{
		T_PROC_NAME td = new T_PROC_NAME();
		StringBuilder strSql = new StringBuilder();
		if(INF_EN_NAME != "" || SUB_ID != -1)
		{
			strSql.append("select * from T_PROC_NAME where INF_EN_NAME = '" + INF_EN_NAME + "' and MAIN_ID in (select PROC_ID from t_sub_power where SUB_ID = '" + SUB_ID + "')");
		}
		else strSql.append("select * from t_proc_name");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.DB_ID = rs.getInt("DB_ID");
				td.INF_CN_NAME = Com_Fun.NoNull(rs.getString("INF_CN_NAME"));
				td.INF_EN_NAME = Com_Fun.NoNull(rs.getString("INF_EN_NAME"));
				td.INF_EN_SQL = Com_Fun.NoNull(rs.getString("INF_EN_SQL"));
				td.INF_TYPE = Com_Fun.NoNull(rs.getString("INF_TYPE"));
				td.REFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_IN_CLASS"));
				td.REFLECT_OUT_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_OUT_CLASS"));
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public List<T_PROC_INPARAM> Get_T_PROC_INPARAM(int PROC_ID)
	{
		List<T_PROC_INPARAM> td = new ArrayList<T_PROC_INPARAM>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_proc_inparam where PROC_ID = " + PROC_ID);
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_PROC_INPARAM tdc = new T_PROC_INPARAM();
				tdc.MAIN_ID = rs.getInt("MAIN_ID");
				tdc.PROC_ID = rs.getInt("PROC_ID");
				tdc.PARAM_CN_NAME = Com_Fun.NoNull(rs.getString("PARAM_CN_NAME"));
				tdc.PARAM_EN_NAME = Com_Fun.NoNull(rs.getString("PARAM_EN_NAME"));
				tdc.PARAM_TYPE = Com_Fun.NoNull(rs.getString("PARAM_TYPE"));
				tdc.PARAM_SIZE = rs.getInt("PARAM_SIZE");
				tdc.IS_URLENCODE = rs.getInt("IS_URLENCODE");
				td.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_INPARAM]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_INPARAM]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public List<T_PROC_OUTPARAM> Get_T_PROC_OUTPARAM(int PROC_ID)
	{
		List<T_PROC_OUTPARAM> td = new ArrayList<T_PROC_OUTPARAM>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_proc_outparam where PROC_ID = " + PROC_ID);
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_PROC_OUTPARAM tdc = new T_PROC_OUTPARAM();
				tdc.MAIN_ID = rs.getInt("MAIN_ID");
				tdc.PROC_ID = rs.getInt("PROC_ID");
				tdc.PARAM_CN_NAME = Com_Fun.NoNull(rs.getString("PARAM_CN_NAME"));
				tdc.PARAM_EN_NAME = Com_Fun.NoNull(rs.getString("PARAM_EN_NAME"));
				tdc.PARAM_TYPE = Com_Fun.NoNull(rs.getString("PARAM_TYPE"));
				tdc.PARAM_SIZE = rs.getInt("PARAM_SIZE");
				td.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_OUTPARAM]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_OUTPARAM]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public List<T_PROC_RETURN> Get_T_PROC_RETURN(int PROC_ID)
	{
		List<T_PROC_RETURN> td = new ArrayList<T_PROC_RETURN>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_proc_return where PROC_ID =" + PROC_ID);
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_PROC_RETURN tdc = new T_PROC_RETURN();
				tdc.MAIN_ID = rs.getInt("MAIN_ID");
				tdc.PROC_ID = rs.getInt("PROC_ID");
				tdc.RETURN_NAME = Com_Fun.NoNull(rs.getString("RETURN_NAME"));
				tdc.RETURN_TYPE = Com_Fun.NoNull(rs.getString("RETURN_TYPE"));
				tdc.IS_IMG = rs.getInt("IS_IMG");
				if(rs.getObject("IS_URLENCODE") != null)
					tdc.IS_URLENCODE = rs.getInt("IS_URLENCODE");
				tdc.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				td.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_RETURN]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_RETURN]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return td;
	}

	public T_SUB_SYS Get_T_SUB_SYS(String SUB_CODE)
	{
		T_SUB_SYS tss = new T_SUB_SYS();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_sub_sys where SUB_CODE ='" + SUB_CODE + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				tss.MAIN_ID = rs.getInt("MAIN_ID");
				tss.SUB_NAME = rs.getString("SUB_NAME");
				tss.SUB_CODE = rs.getString("SUB_CODE");
				if(rs.getObject("IP_ADDR") != null)
					tss.IP_ADDR = rs.getString("IP_ADDR");
				tss.LIMIT_DATE = rs.getDate("LIMIT_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("LIMIT_DATE")));
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_SYS]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_SYS]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tss;
	}

	public T_SUB_USERPOWER Get_T_SUB_USERPOWER(int sub_user_id,int proc_id)
	{
		T_SUB_USERPOWER tsp = new T_SUB_USERPOWER();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_sub_userpower where SUB_USER_ID ='" + sub_user_id + "' and PROC_ID = '" + proc_id + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				tsp.MAIN_ID = rs.getInt("MAIN_ID");
				tsp.SUB_USER_ID = rs.getInt("sub_user_id");
				tsp.PROC_ID = rs.getInt("proc_id");
				tsp.LIMIT_DATE = rs.getDate("LIMIT_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("LIMIT_DATE")));// rs.getDate("LIMIT_DATE");
				tsp.USE_LIMIT = rs.getInt("USE_LIMIT");
				tsp.LIMIT_NUMBER = rs.getInt("LIMIT_NUMBER");
				tsp.LIMIT_TAG = rs.getString("LIMIT_TAG");
				tsp.FIRST_DATE = rs.getDate("FIRST_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("FIRST_DATE")));// rs.getDate("FIRST_DATE");//rs.getDate("FIRST_DATE");
				tsp.S_DESC = rs.getString("S_DESC");
				tsp.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("CREATE_DATE")));// rs.getDate("CREATE_DATE");//rs.getDate("CREATE_DATE");
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_USERPOWER]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_USERPOWER]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tsp;
	}

	public T_SUB_USER Get_T_SUB_USER(int sub_id,String sub_usercode)
	{
		T_SUB_USER tsp = new T_SUB_USER();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_sub_user where SUB_USERCODE ='" + sub_usercode + "' and SUB_ID = '" + sub_id + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				tsp.MAIN_ID = rs.getInt("MAIN_ID");
				tsp.SUB_ID = rs.getInt("SUB_ID");
				tsp.SUB_USERNAME = rs.getString("SUB_USERNAME");
				tsp.SUB_USERCODE = rs.getString("SUB_USERCODE");
				tsp.LIMIT_DATE = rs.getDate("LIMIT_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("LIMIT_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				tsp.S_DESC = rs.getString("S_DESC");
				tsp.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("CREATE_DATE")));// rs.getDate("CREATE_DATE");
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_USER]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_USER]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tsp;
	}

	public T_SUB_POWER Get_T_SUB_POWER(int SUB_ID,int PROC_ID)
	{
		T_SUB_POWER tsp = new T_SUB_POWER();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_sub_power where SUB_ID ='" + SUB_ID + "' and PROC_ID = '" + PROC_ID + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				tsp.MAIN_ID = rs.getInt("MAIN_ID");
				tsp.SUB_ID = rs.getInt("MAIN_ID");
				tsp.PROC_ID = rs.getInt("MAIN_ID");
				tsp.LIMIT_DATE = rs.getDate("LIMIT_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("LIMIT_DATE")));// rs.getDate("LIMIT_DATE");
				tsp.USE_LIMIT = rs.getInt("USE_LIMIT");
				tsp.LIMIT_NUMBER = rs.getInt("LIMIT_NUMBER");
				tsp.LIMIT_TAG = rs.getString("LIMIT_TAG");
				tsp.FIRST_DATE = rs.getDate("FIRST_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("FIRST_DATE"))); // rs.getDate("FIRST_DATE"));//rs.getDate("FIRST_DATE");
				tsp.S_DESC = rs.getString("S_DESC");
				tsp.CREATE_DATE = rs.getDate("CREATE_DATE") == null ? (new SimpleDateFormat("yyyy-MM-dd").parse("1900-1-1")) : (new SimpleDateFormat("yyyy-MM-dd").parse(rs.getString("CREATE_DATE"))); // rs.getDate("CREATE_DATE"));//rs.getDate("FIRST_DATE");
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_POWER]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_SUB_POWER]\r\n" + strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return tsp;
	}

	private void Change_Child_Code(String Child_Code)
	{
		Db_Common_Self dbc_ic = new Db_Common_Self();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_param_value where PARAM_KEY = 'Child_Code'");
		ResultSet rs = dbc_ic.Common_Sql(strSql);
		try
		{
			boolean bFlag = false;
			while(rs.next())
			{
				bFlag = true;
				break;
			}
			strSql.delete(0,strSql.length());
			if(bFlag)
			{
				strSql.append("update t_param_value set PARAM_VALUE='" + Child_Code + "' where PARAM_KEY = 'Child_Code'");
			}
			else
			{
				strSql.append("insert into t_param_value(PARAM_KEY,PARAM_VALUE,PARAM_NAME,S_DESC,CREATE_DATE) " + " values('Child_Code','" + Child_Code + "','本设备唯一编码','',sysdate());");
			}
			dbc_ic.CommonExec_Sql(strSql);
		}
		catch(Exception e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Change_Child_Code]\r\n" + strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
	}

	/************************************/
	private List<Integer> Get_MAIN(StringBuilder strSql)
	{
		List<Integer> liMainID = new ArrayList<Integer>();
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				liMainID.add(rs.getInt("MAIN_ID"));
			}
		}
		catch(Exception es)
		{
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return liMainID;
	}

	public void InitData()
	{
		String[] strSubTable = {"t_proc_name"};
		StringBuilder strSql = new StringBuilder("select * from t_db_config order by cast(MAIN_ID as int)");
		Ope_InitData("t_db_config",strSubTable,"DB_ID",strSql);

		String[] strSubTable1 = {"t_proc_inparam","t_proc_outparam","t_proc_return","t_sub_power","t_sub_userpower","t_proc_log","t_page_item"};
		strSql.delete(0,strSql.length());
		strSql.append("select * from t_proc_name order by cast(DB_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_proc_name",strSubTable1,"PROC_ID",strSql);

		strSubTable = new String[0];
		strSql.delete(0,strSql.length());
		strSql.append("select * from t_proc_inparam order by cast(PROC_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_proc_inparam",strSubTable,"PROC_ID",strSql);

		strSql.delete(0,strSql.length());
		strSql.append("select * from t_proc_outparam order by cast(PROC_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_proc_outparam",strSubTable,"PROC_ID",strSql);

		strSql.delete(0,strSql.length());
		strSql.append("select * from t_proc_return order by cast(PROC_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_proc_return",strSubTable,"PROC_ID",strSql);

		strSql.delete(0,strSql.length());
		strSql.append("select * from t_sub_power order by cast(PROC_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_sub_power",strSubTable,"PROC_ID",strSql);

		strSql.delete(0,strSql.length());
		strSql.append("select * from t_sub_userpower order by cast(PROC_ID as int),cast(MAIN_ID as int)");
		Ope_InitData("t_sub_userpower",strSubTable,"PROC_ID",strSql);

		strSql.delete(0,strSql.length());
		strSql.append("select * from t_proc_log order by cast(MAIN_ID as int)");
		Ope_InitData("t_proc_log",strSubTable,"PROC_ID",strSql);
		System.out.println("over");
	}

	private boolean Ope_InitData(String strParTable,String[] strSubTable,String strSubPID,StringBuilder strSelPID)
	{
		boolean bResult = true;
		Db_Common_Self dbc_ic = new Db_Common_Self();
		StringBuilder strSql = new StringBuilder();
		strSql.append("update " + strParTable + " set MAIN_ID = MAIN_ID + 1000 where MAIN_ID < 1000");
		dbc_ic.CommonExec_Sql(strSql);
		System.out.println("upd父表:" + strSql);
		for(String strtb_name: strSubTable)
		{
			strSql.delete(0,strSql.length());
			strSql.append("update " + strtb_name + " set " + strSubPID + "=" + strSubPID + "+1000 where " + strSubPID + " < 1000");
			dbc_ic.CommonExec_Sql(strSql);
		}

		List<Integer> liMainID = Get_MAIN(strSelPID);
		int i = 0;
		for(int iMAIN_ID: liMainID)
		{
			i++;
			strSql.delete(0,strSql.length());
			strSql.append("update " + strParTable + " set MAIN_ID = " + i + " where MAIN_ID = " + iMAIN_ID);
			PooledConnection_Self conn = null;
			try
			{
				conn = dbc_ic.BeginTransaction();
				dbc_ic.CommonExec_Sql(conn,strSql);
				System.out.println("sql父表:" + strSql);
				StringBuilder strSql1 = new StringBuilder();
				for(String strtb_name: strSubTable)
				{
					strSql1.delete(0,strSql1.length());
					strSql1.append("update " + strtb_name + " set " + strSubPID + "=" + i + " where " + strSubPID + "=" + iMAIN_ID);
					System.out.println("sql子表:" + strSql1);
					dbc_ic.CommonExec_Sql(conn,strSql1);
				}
				conn.CommitTranSaction();
			}
			catch(SQLException e)
			{
				e.printStackTrace();
				bResult = false;
				try
				{
					conn.RollBackTranSaction();
				}
				catch(SQLException e1)
				{
				}
			}
			finally
			{
				conn.returnConnection();
			}
		}
		return bResult;
	}

	/******************************/
	public boolean Ope_Data_Number(T_SUB_POWER tsp,T_SUB_USERPOWER tsup,int proc_id)
	{
		boolean bResult = true;
		Db_Common_Self dbc_ic = new Db_Common_Self();
		StringBuilder strSql = new StringBuilder();
		PooledConnection_Self conn = null;
		ResultSet rs = null;
		try
		{
			conn = dbc_ic.BeginTransaction();
			if(tsup.MAIN_ID != -1)
			{
				String strForatS = "yyyy-MM-dd";
				if(tsup.LIMIT_TAG.equals("1"))
					strForatS = "yyyy";
				else if(tsup.LIMIT_TAG.equals("2"))
					strForatS = "yyyy-MM";
				if(tsup.LIMIT_TAG.equals("3"))
					strForatS = "yyyy-MM-dd";

				if(new SimpleDateFormat(strForatS).format(new Date()).equals(new SimpleDateFormat(strForatS).format(tsup.FIRST_DATE)))
				{
					strSql.append("update t_sub_userpower set USE_LIMIT = USE_LIMIT + 1 where MAIN_ID = '" + tsup.MAIN_ID + "'");
				}
				else
				{
					strSql.append("update t_sub_userpower set USE_LIMIT = 1,FIRST_DATE = '" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "' where MAIN_ID = '" + tsup.MAIN_ID + "'");
				}
				dbc_ic.CommonExec_Sql(conn,strSql);
			}
			String strDtDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
			if(tsup.MAIN_ID == -1 && tsp.MAIN_ID != -1)
			{
				String strForatS = "yyyy-MM-dd";
				if(tsup.LIMIT_TAG.equals("1"))
					strForatS = "yyyy";
				else if(tsup.LIMIT_TAG.equals("2"))
					strForatS = "yyyy-MM";
				if(tsup.LIMIT_TAG.equals("3"))
					strForatS = "yyyy-MM-dd";
				strSql.delete(0,strSql.length());
				if(new SimpleDateFormat(strForatS).format(new Date()).equals(new SimpleDateFormat(strForatS).format(tsp.FIRST_DATE)))
				{
					strSql.append("update t_sub_power set USE_LIMIT = USE_LIMIT + 1 where MAIN_ID = '" + tsp.MAIN_ID + "'");
				}
				else
				{
					strSql.append("update t_sub_power set USE_LIMIT = 1,FIRST_DATE = '" + strDtDate + "' where MAIN_ID = '" + tsp.MAIN_ID + "'");
				}
				dbc_ic.CommonExec_Sql(conn,strSql);
			}
			strSql.delete(0,strSql.length());
			strSql.append("select * from t_proc_log where SUB_USER_ID = '" + tsup.SUB_USER_ID + "'  and PROC_ID = '" + proc_id + "' and SYS_DATE = '" + strDtDate + "'");
			rs = dbc_ic.Common_Sql(conn,strSql);
			boolean bFlag = false;
			while(rs.next())
			{
				bFlag = true;
				break;
			}
			strSql.delete(0,strSql.length());
			if(bFlag)
			{
				strSql.append("update t_proc_log set S_COUNT = S_COUNT+1 where SUB_USER_ID = '" + tsup.SUB_USER_ID + "'  and PROC_ID = '" + proc_id + "' and SYS_DATE = '" + strDtDate + "'");
			}
			else
			{
				strSql.append("insert into t_proc_log(SUB_USER_ID,PROC_ID,S_COUNT,SYS_DATE,S_DESC,CREATE_DATE) " + " values('" + tsup.SUB_USER_ID + "','" + proc_id + "','1','" + strDtDate + "','','" + strDtDate + "')");
			}
			dbc_ic.CommonExec_Sql(conn,strSql);
			conn.CommitTranSaction();
		}
		catch(SQLException e)
		{
			e.printStackTrace();
			bResult = false;
			try
			{
				conn.RollBackTranSaction();
			}
			catch(SQLException e1)
			{
			}
		}
		finally
		{
			try
			{
				conn.returnConnection();
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e1)
			{
			}
		}
		return bResult;
	}
}